<?php
/**
 * @version $Id: wrd.php 428 2012-03-28 12:03:35Z lnmtrung@gmail.com $
 */

defined('_JEXEC') or die('Restricted access');

class JHTMLwrd{
	
	public static function listCountry($name, $active=NULL,$javascript='',$class ='', $first=-1 ){
		
		$model = &JModelLegacy::getInstance('country','WrdModel');
		$states = array();
		$states[] = JHTML::_('select.option', '249', JText::_('WRD_OPT_VIETNAM'), 'value', 'text');
		$states = array_merge( $states, $model->getList());
		$state = JHTML::_('select.genericList', $states,$name, 'class="inputbox '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listViewOptionFrontEnd($name, $active=NULL,$javascript='',$class ='', $first=-1 ){
		
		$states = array();
		$states[] = JHTML::_('select.option', '0', '- '.JText::_('WRD_OPT_SELECT').' -', 'value', 'text');
		$states[] = JHTML::_('select.option', '1', JText::_('WRD_OPT_SELECT_THIS_MONTH'), 'value', 'text');
		$states[] = JHTML::_('select.option', '2', JText::_('WRD_OPT_SELECT_LAST_MONTH'), 'value', 'text');
		$states[] = JHTML::_('select.option', '3', JText::_('WRD_OPT_SELECT_LAST_THREE_MONTH'), 'value', 'text');
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="inputbox '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listRule($name, $active=NULL,$javascript='',$class ='', $first=-1 ){
		$states = array();
		$states[] = JHTML::_('select.option', '6', 'Rule 0: Setup manually discount', 'value', 'text');
		$states[] = JHTML::_('select.option', '1', 'Rule 1: Birthday', 'value', 'text');
		$states[] = JHTML::_('select.option', '1a', 'Rule 1a: Birthday (month)', 'value', 'text');
		$states[] = JHTML::_('select.option', '2', 'Rule 2: 1st time of using card', 'value', 'text');
		$states[] = JHTML::_('select.option', '3', 'Rule 3: the 20th VIP member at the restaurant', 'value', 'text');
		$states[] = JHTML::_('select.option', '4', 'Rule 4: Points reach 10,000 points or 20,000 points etc…', 'value', 'text');
		$states[] = JHTML::_('select.option', '5', 'Rule 5: The lucky draw number', 'value', 'text');

		$state = JHTML::_('select.genericList', $states,$name, 'class="inputbox '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}

	public static function listRuleOff($name, $active=NULL,$javascript='',$class ='', $first=-1 ){
	
		$states = array();
		
		$states[] = JHTML::_('select.option', '1', 'Rule 1: Birthday', 'value', 'text');
		$states[] = JHTML::_('select.option', '1a', 'Rule 1a: Birthday (month)', 'value', 'text');
		$states[] = JHTML::_('select.option', '5', 'Rule 5: The lucky draw number', 'value', 'text');
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="inputbox '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listCurrency($name, $active=NULL, $javascript='', $class ='', $order='', $size=1){
		$model = &JModelLegacy::getInstance('currency','WrdModel');
		$states = array();
		$states = array_merge( $states, $model->getList());
		$state = JHTML::_('select.genericList', $states,$name, 'class="inputbox '.$class.'"  size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
    public static function lprefer($name, $active=NULL, $javascript='', $class ='', $order='', $size=1){
		$model = &JModelLegacy::getInstance('lprefer','WrdModel');
		$states = array();
		$states[] = JHTML::_('select.option', '0', JText::_('WRD_OPT_SELECT_LANGUAGE'), 'value', 'text');
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_LANGUAGE_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);
		$state = JHTML::_('select.genericList', $states,$name, 'class="inputbox '.$class.'"  size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
    
	public static function filter_verify($active=0,$javascript='',$first = 1){
		if($first == 1)
			$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Verify').' -', 'value', 'text');
		
		$states[] = JHTML::_('select.option', '0', JText::_( 'Verified' ));
		$states[] = JHTML::_('select.option', '1', JText::_( 'Unverify' ));
		$state = JHTML::_('select.genericList', $states,'waiting_verify', 'class="inputbox"  size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function filter_call_confirm($active=0,$javascript='',$first = 1){
		if($first == 1)
			$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Confirm').' -', 'value', 'text');
		
		$states[] = JHTML::_('select.option', '1', JText::_( 'Confirmed' ));
		$states[] = JHTML::_('select.option', '0', JText::_( 'Unconfirm' ));
		$state = JHTML::_('select.genericList', $states,'call_confirm', 'class="inputbox"  size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function filter_card_process($active=0,$javascript='',$first = 1){
		if($first == 1)
			$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Process').' -', 'value', 'text');
		
		$states[] = JHTML::_('select.option', '1', JText::_( 'Processing' ));
		$states[] = JHTML::_('select.option', '0', JText::_( 'Not process' ));
		$state = JHTML::_('select.genericList', $states,'card_process', 'class="inputbox"  size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function filter_non_pickup($active=0,$javascript='',$first = 1){
		if($first == 1)
			$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Pick up').' -', 'value', 'text');
		
		$states[] = JHTML::_('select.option', '0', JText::_( 'Picked up' ));
		$states[] = JHTML::_('select.option', '1', JText::_( 'None pick up' ));
		$state = JHTML::_('select.genericList', $states,'none_pick_up', 'class="inputbox"  size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function profileFillter($active=0,$javascript=''){
		$states[] = JHTML::_('select.option', '0', '- All -', 'value', 'text');
		$states[] = JHTML::_('select.option', '1', JText::_( 'Waiting for Verify' ));
		$states[] = JHTML::_('select.option', '2', JText::_( 'Non Pick up' ));
		$state = JHTML::_('select.genericList', $states,'profilefillter', 'class="inputbox"  size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function searchFillter($active=0){
		$javascript = '';
		$states[] = JHTML::_('select.option', '0', '- All -', 'value', 'text');
		$states[] = JHTML::_('select.option', '1', JText::_( 'User\'s name'));
		$states[] = JHTML::_('select.option', '2', JText::_( 'Member id'));
		$states[] = JHTML::_('select.option', '3', JText::_( 'User\'s phone'));
		$states[] = JHTML::_('select.option', '4', JText::_( 'User\'s Company'));
		$states[] = JHTML::_('select.option', '5', JText::_( 'User\'s Email'));
		$state = JHTML::_('select.genericList', $states,'searchfillter[]', 'class="inputbox" multiple size="4" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	public static function dateFillter($active=0){
		$javascript = '';
		$states[] = JHTML::_('select.option', '0', '- All -', 'value', 'text');
		$states[] = JHTML::_('select.option', '1', JText::_( 'Birth Day'));
		$states[] = JHTML::_('select.option', '2', JText::_( 'Created Day'));
		$state = JHTML::_('select.genericList', $states,'datefillter[]', 'class="inputbox" multiple size="3" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	public static function orderfield($active=0){
		$states[] = JHTML::_('select.option', '0', '- All -', 'value', 'text');
		$states[] = JHTML::_('select.option', 'l_name', JText::_( 'User\'s name'));
		$states[] = JHTML::_('select.option', 'member_id', JText::_( 'Member id'));
		$states[] = JHTML::_('select.option', 'phone', JText::_( 'User\'s phone'));
		$states[] = JHTML::_('select.option', 'company_name', JText::_( 'User\'s Company'));
		$states[] = JHTML::_('select.option', 'created_date', JText::_( 'Created Date'));
		$states[] = JHTML::_('select.option', 'modify_by', JText::_( 'Modify by'));
		$states[] = JHTML::_('select.option', 'modify_date', JText::_( 'Modify date'));
		$states[] = JHTML::_('select.option', 'modify_date', JText::_( 'Pickup date'));	
		$state = JHTML::_('select.genericList', $states,'order_field[]', 'class="inputbox" multiple="multiple" size="4" ', 'value', 'text', $active);
		return $state;
	}
	
	public static function filter_pick_up_outlet($active=0,$javascript='',$first = 1){
		$model = &JModelLegacy::getInstance('outlets','WrdModel');
		$states = array();
		$states[] = JHTML::_('select.option', '', '- '.JText::_('Outlet').' -', 'value', 'text');
		$states = array_merge( $states, $model->getList());
		$state = JHTML::_('select.genericList', $states , 'pick_up_at', 'class="pick_up_at" size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function all_outlet($active=0,$javascript='',$first = 1){
		$model = &JModelLegacy::getInstance('outlets','WrdModel');
		$states = array();
		$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Outlet').' -', 'value', 'text');
		$states = array_merge( $states, $model->getListAll());
		$state = JHTML::_('select.genericList', $states , 'o_id', 'class="o_id" size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function filter_active($active=0,$javascript='',$first = 1){
		if($first == 1)
			$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Select status').' -', 'value', 'text');
		
		$states[] = JHTML::_('select.option', '1', JText::_( 'actived' ));
		$states[] = JHTML::_('select.option', '0', JText::_( 'Not active' ));
		$state = JHTML::_('select.genericList', $states,'active', 'class="inputbox"  size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function published($active=0,$javascript='',$first = 1){
		if($first == 1)
			$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Select status').' -', 'value', 'text');
		
		$states[] = JHTML::_('select.option', '1', JText::_( 'Publish' ));
		$states[] = JHTML::_('select.option', '0', JText::_( 'Unpublish' ));
		$state = JHTML::_('select.genericList', $states,'published', 'class="inputbox"  size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function prefix($active=0,$javascript='',$first = 1, $class=''){
		if($first == 1)
			$states[] = JHTML::_('select.option', '-1', '- '.JText::_('WRD_OPT_SELECT').' -', 'value', 'text');
		$states[] = JHTML::_('select.option', 'Prof.', JText::_( 'WRD_OPT_SELECT_PROF' ));
		$states[] = JHTML::_('select.option', 'Dr.', JText::_( 'WRD_OPT_SELECT_DR' ));
		$states[] = JHTML::_('select.option', 'Mr.', JText::_( 'WRD_OPT_SELECT_MR' ));
		$states[] = JHTML::_('select.option', 'Ms.', JText::_( 'WRD_OPT_SELECT_MS' ));
		$states[] = JHTML::_('select.option', 'Mrs.', JText::_( 'WRD_OPT_SELECT_MRS' ));
		$state = JHTML::_('select.genericList', $states,'prefix', 'class="'.$class.'" size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function action($active=0,$javascript='',$first = 1){
		if($first == 1)
			$states[] = JHTML::_('select.option', 'no', '- '.JText::_('Select action').' -', 'value', 'text');
		
		$states[] = JHTML::_('select.option', 'registration', JText::_( 'Registration' ));
		$states[] = JHTML::_('select.option', 'verify', JText::_( 'Verify' ));
		$states[] = JHTML::_('select.option', 'renew', JText::_( 'Renew Account' ));
		$states[] = JHTML::_('select.option', 'pickup_notice', JText::_( 'Pick Up Notice' ));
		$states[] = JHTML::_('select.option', 'birthday', JText::_( 'Birthday' ));
		$states[] = JHTML::_('select.option', 'redemption_notice', JText::_( 'Redemption Notice' ));
		$states[] = JHTML::_('select.option', 'redemption_pick_up_notice', JText::_( 'Redemption Pick Up Notice' ));
		$states[] = JHTML::_('select.option', 'complaints', JText::_( 'Complaints' ));
		$states[] = JHTML::_('select.option', 'reset_pass', JText::_( 'Reset Password' ));
		$states[] = JHTML::_('select.option', 'birthday_notification_report', JText::_( 'Birthday Notification Report' ));
		$states[] = JHTML::_('select.option', 'changed_fields_send_to_admin', JText::_( 'Changed Fields on Profile'));
		$state = JHTML::_('select.genericList', $states,'action', 'class="actions"  size="1" '.$javascript, 'value', 'text', $active);
		
		return $state;
	}
	
	public static function type_user($active=0,$javascript='',$first = 1){
		if($first == 1)
			$states[] = JHTML::_('select.option', 'no', '- '.JText::_('Type user').' -', 'value', 'text');
		
		$states[] = JHTML::_('select.option', 'user', JText::_( 'User' ));
		$states[] = JHTML::_('select.option', 'admin', JText::_( 'Admin' ));
		$state = JHTML::_('select.genericList', $states,'type', 'class="type"  size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function dateOfWeek(){
		$states[] = JHTML::_('select.option', '', JText::_( '- Select day - ' ));
		$states[] = JHTML::_('select.option', 'mon', JText::_( 'Mon' ));
		$states[] = JHTML::_('select.option', 'tue', JText::_( 'Tue' ));
		$states[] = JHTML::_('select.option', 'wed', JText::_( 'Wed' ));
		$states[] = JHTML::_('select.option', 'thu', JText::_( 'Thu' ));
		$states[] = JHTML::_('select.option', 'fri', JText::_( 'Fri' ));
		$states[] = JHTML::_('select.option', 'sat', JText::_( 'Sat' ));
		$states[] = JHTML::_('select.option', 'sun', JText::_( 'Sun' ));
		
		$state = JHTML::_('select.genericList', $states,'day', 'class="day" size="1" ', 'value', 'text' );
		return $state;
	}
	
	public static function gender($active=0,$name = 'gender'){
		$states[] = JHTML::_('select.option', '0', JText::_( '- Select gender -' ));
		$states[] = JHTML::_('select.option', 'male', JText::_( 'Male' ));
		$states[] = JHTML::_('select.option', 'female', JText::_( 'Female' ));
		$states[] = JHTML::_('select.option', 'other', JText::_( 'Other' ));
		$state = JHTML::_('select.genericList', $states,$name, 'class="inputbox"  size="1" ', 'value', 'text', $active );
		return $state;
	}
	
	public static function type_service($active=0,$name = 'type_service',$class='type_service'){
		$states[] = JHTML::_('select.option', '', JText::_( '- selectet type -' ));
		$states[] = JHTML::_('select.option', 'f', JText::_( 'Food' ));
		$states[] = JHTML::_('select.option', 'b', JText::_( 'Beverate' ));
		$states[] = JHTML::_('select.option', 't', JText::_( 'Sevice' ));
		$states[] = JHTML::_('select.option', 'o', JText::_( 'Other' ));
		$state = JHTML::_('select.genericList', $states,$name, 'class='.$class.'  size="1" ', 'value', 'text', $active );
		return $state;
	}
	
	public static function time_on($active=0,$name = 'time_on',$class='time_on'){
		$states[] = JHTML::_('select.option', '', JText::_( '- selectet time -' ));
		$states[] = JHTML::_('select.option', 'm', JText::_( 'Morning' ));
		$states[] = JHTML::_('select.option', 'a', JText::_( 'Afternoon' ));
		$states[] = JHTML::_('select.option', 'e', JText::_( 'Evening' ));
		$state = JHTML::_('select.genericList', $states,$name, 'class='.$class.'  size="1" ', 'value', 'text', $active );
		return $state;
	}
	
	//use for fillter itemid
	public static function listUser($name, $active=NULL, $javascript='',$table = '' , $order='', $size=1){
		$model = &JModelLegacy::getInstance($table,'WrdModel');
		
		$states = array();
		$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Select User').' -', 'value', 'text');
		$rs = $model->getUserList();
		if(count($rs) == 0)
			return null;
		$states = array_merge( $states,$rs);
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="inputbox"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function sexIcon($value, $img1 = 'female.png', $img0 = 'male.png')
	{
		$img	= $value == 'male' ? $img0 : $img1;
		$alt	= $value == 'male' ? 'Male' : 'Female';
		$href = '<img src="components/com_activities/assets/images/'.$img.'" />';
		return $href;
	}
	
	public static function age($name, $active = null, $class){
		for($i = 1 ; $i< 100; $i++)
			$states[] = JHTML::_('select.option', $i, $i);

		$state = JHTML::_('select.genericList', $states,$name, 'class="inputbox. '.$class.'"  size="1" ', 'value', 'text', $active );
		return $state;
	}
	
	public static function act_time($name, $active = null,$limit = 24, $class =''){
		for($i = 0 ; $i< $limit; $i++){
			if(strlen($i) == 1)
				$tmp = '0'.$i;
			else
				$tmp = $i; 
			$states[] = JHTML::_('select.option', $i, $tmp);
		}

		$state = JHTML::_('select.genericList', $states,$name, 'class="inputbox. '.$class.'"  size="1" ', 'value', 'text', $active );
		return $state;
	}
	
	public static function listProjects($name, $active=NULL, $javascript='', $class , $first= '-1'){
		$model = &JModelLegacy::getInstance('projects','WrdModel');
		$states = array();
		if($first!=-1){
			$states[] = JHTML::_('select.option', '', '- '.JText::_('Select project').' -', 'value', 'text');
		}
		
		$states = array_merge( $states, $model->getList());
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="pid "'.$class.' size="1" '.$javascript, 'value', 'text', 01);
		
		return $state;
	}
	
	public static function projectToClub(){
		$db = JFactory::getDBO();
		$query = '
			SELECT c.code, c.name, c.pid 
			FROM #__wrd_club as c
			WHERE c.published = 1 ORDER BY c.pid ';
		
		$db->setQuery($query);
		$state = $db->loadObjectList();
		return $state;
	}
	
	public static function listClubs($name, $active=NULL, $javascript='', $class ='',$flag_pcode = 0){
		$model = &JModelLegacy::getInstance('clubs','WrdModel');
		$states = array();
		$states[] = JHTML::_('select.option', '', '- '.JText::_('WRD_OPT_SELECT_CLUB').' -', 'value', 'text');
		$a = $model->getList($flag_pcode);
		if($active!=NULL){
			$states = array_merge($states,$a);
		}
		$state = JHTML::_('select.genericList', $a,$name, 'class="cid" '.$class.' size="1" '.$javascript, 'value', 'text',01);

		return $state;
	}
	
	public static function clubToOutlet(){
	
		$db = JFactory::getDBO();
		$query = '
			SELECT o.code, o.name, o.cid
			FROM #__wrd_outlets as o  
			WHERE (o.published = 1 AND o.published_cpoint = 1) ORDER BY o.cid ' ;
		$db->setQuery($query);
		$state = array();
		
		$state = $db->loadObjectList();
		$state = array_merge($state);
 		return $state;
	}

	public static function listOutlets($name,$active=NULL,$javascript='',$class ='',$flag_pcode = 0, $condition=''){
		$model = &JModelLegacy::getInstance('outlets','WrdModel');
		$states = array();
		$states[] = JHTML::_('select.option','-1', '- '.JText::_('WRD_OPT_SELECT_ALL').' -', 'value', 'text');
		$states = array_merge( $states, $model->getList($condition));
		
		$state = JHTML::_('select.genericList', $states , $name, 'class="'.$class.'" size="1" '.$javascript, 'value', 'text', $active );
		
		return $state;
	}
	
	public static function listOutletInAddTransaction($name,$active=NULL,$javascript='',$class ='',$flag_pcode = 0, $condition=''){
		$model = &JModelLegacy::getInstance('outlets','WrdModel');
		$states = array();
		$states = array_merge( $states, $model->getList($condition));
		$state = JHTML::_('select.genericList', $states , $name, 'class="'.$class.'" size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listOutletsP($name,$active=NULL,$javascript='',$class ='',$flag_pcode = 0, $condition=''){
		$model = &JModelLegacy::getInstance('outlets','WrdModel');
		$states = array();
		$states[] = JHTML::_('select.option', '',JText::_('WRD_OPT_SELECT_OUTLETS'), 'value', 'text');
		$list = $model->getListOutlets($condition);
		foreach ($list as $raw=>$item){
			if($item->published_cpoint == 1)
				$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_OUTLETS_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);
		$state = JHTML::_('select.genericList', $states , $name, 'class="'.$class.'" size="1" '.$javascript, 'value', 'text', $active );
		return $state; 
	}
    public static function listOutletsEx2($name,$active=NULL,$javascript='',$class ='',$flag_pcode = 0, $condition=''){
        $model = &JModelLegacy::getInstance('outlets','WrdModel');
        $states = array();
        $states = array_merge( $states, $model->getList($condition));
		$state = JHTML::_('select.genericList', $states , $name, 'class="'.$class.'" size="1" '.$javascript, 'value', 'text', $active );
        return $state;
    }
    
    public static function listHandleBy($name,$active=NULL,$javascript='',$class ='',$flag_pcode = 0, $condition=''){
        $model = &JModelLegacy::getInstance('complain','WrdModel');
        $states = array(); 
        $states[] = JHTML::_('select.option', '', ''.JText::_('WRD_OPT_SELECT_ALL').'', 'value', 'text');
        $states = array_merge( $states, $model->complainHandleBy());
        $state = JHTML::_('select.genericList', $states , $name, 'class="'.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
        return $state;
    }
    
	public static function point_listProjects($name, $active=NULL, $javascript='', $class , $first= '-1'){
		$model = &JModelLegacy::getInstance('projects','WrdModel');
		$states = array();
		if($first!=-1){
			$states[] = JHTML::_('select.option', '0', '- '.JText::_('WRD_OPT_SELECT_PROJECT').' -', 'value', 'text');
		}
		
		$states = array_merge( $states, $model->point_getList());
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="pid "'.$class.' size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function point_projectToClub(){
		$db = JFactory::getDBO();
		$query = '
			SELECT c.id, c.name, p.code as p_code 
			FROM #__wrd_club as c
			LEFT JOIN #__wrd_projects as p ON p.id = c.pid 
			WHERE c.published = 1 ORDER BY p_code ';
		
		$db->setQuery($query);
		$state = $db->loadObjectList();
		return $state;
	}
	
	public static function point_listClubs($name, $active=NULL, $javascript='', $class =''){
		$model = &JModelLegacy::getInstance('clubs','WrdModel');
		$states = array();
		$states[] = JHTML::_('select.option', '0', '- '.JText::_('WRD_OPT_SELECT_CLUB').' -', 'value', 'text');
		if($active!=NULL)
			$states = array_merge( $states, $model->point_getList());
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="cid" '.$class.' size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function point_clubToOutlet(){
		$db = JFactory::getDBO();
		
			$query = '
			SELECT o.id, o.name, c.code as c_code 
			FROM #__wrd_outlets as o
			LEFT JOIN #__wrd_club as c ON  c.id = o.cid 
			WHERE o.published = 1 ORDER BY c_code ' ;
		
		$db->setQuery($query);
		$state = $db->loadObjectList();
		return $state;
	}
	
	public static function point_listOutlets($name,$active=NULL,$javascript='',$class =''){
		$model = &JModelLegacy::getInstance('outlets','WrdModel');
		$states = array();
		$states[] = JHTML::_('select.option', '0', '- '.JText::_('WRD_OPT_SELECT_OUTLETS').' -', 'value', 'text');
		$states = array_merge( $states, $model->point_getList());
		$state = JHTML::_('select.genericList', $states , $name, 'class="'.$class.'" size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
    
    public static function listFieldReport($name, $active=NULL, $javascript='', $class ='')
    {    
        $states = array();        
        $states[] = JHTML::_('select.option', '', JText::_('All'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'cover', JText::_('Cover'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'food', JText::_('Food'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'beverage', JText::_('Beverage Alcoholic'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'other', JText::_('Misc./Ciger'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'vat', JText::_('Service & Tax Total'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'averagespending', JText::_('Average Spending per cover'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'foodratio', JText::_('Food ratio'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'bvratio', JText::_('BV Ratio'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'miscratio', JText::_('Misc Ratio'), 'value', 'text');
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" size=15 multiple="multiple" '.$javascript, 'value', 'text', $active);
        return $state;
    }
    
    /*
     * For member pending report detail
     * Choose to decide which field to display
     */
    public static function listFieldReportDetail($name, $active=NULL, $javascript='', $class ='')
    {    
        $states = array();        
        $states[] = JHTML::_('select.option', '', JText::_('All'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'totalvisit', JText::_('Total Visit'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'cover', JText::_('Cover'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'food', JText::_('Food'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'beverage', JText::_('Beverage Alcoholic'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'other', JText::_('Misc./Ciger'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'vat', JText::_('VAT'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'service', JText::_('Service Charge'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'averagespending', JText::_('Average Spending per cover'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'foodratio', JText::_('Food ratio'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'bvratio', JText::_('BV Ratio'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'miscratio', JText::_('Misc Ratio'), 'value', 'text');
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" size=15 multiple="multiple" '.$javascript, 'value', 'text', $active);
        return $state;
    }
    
    /*
     * Status for VIP Membership Club Report
     */
    public static function listFieldExtraStatus($name, $active=NULL, $javascript='', $class ='')
    {    
        $states = array();               
        $states[] = JHTML::_('select.option', 'active', JText::_('Active'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'nonactive', JText::_('Inactive'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'pickup', JText::_('Pick up'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'nonpickup', JText::_('Non pick up'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'newjoin', JText::_('New join'), 'value', 'text');        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" size=15 multiple="multiple" '.$javascript, 'value', 'text', $active);
        return $state;
    }
    
    /*
     * Member Type List
     */
    public static function memberTypeList($name, $active=NULL, $javascript='', $class ='')
    {    
        $states = array();        
        $states[] = JHTML::_('select.option', '', JText::_('All'), 'value', 'text');
        $statusList = self::memberTypeRaw();
        foreach($statusList as $key => $value)
        {
            $states[] = JHTML::_('select.option', $key, $value, 'value', 'text');
        }
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" multiple="multiple" size="4" '.$javascript, 'value', 'text', $active);
        return $state;
    }
    
    public static function memberTypeRaw()
    {
        return array(
            '1_0_0_0, 1_0_0_1, 1_0_1_0, 1_0_1_1, 1_1_0_0, 1_1_0_1, 1_1_1_0, 1_1_1_1' => 'Top Spenders',
            '1_1_0_0, 1_1_0_1, 1_1_1_0, 1_1_1_1, 0_1_0_0, 0_1_0_1, 0_1_1_0, 0_1_1_1' => 'New Join Members',
            '1_1_1_0, 1_1_1_1, 1_0_1_0, 1_0_1_1, 0_0_1_0, 0_1_1_0, 0_0_1_1, 0_1_1_1' => 'Inactive Members',
			'0_0_0_1, 0_0_1_1, 0_1_0_1, 0_1_1_1, 1_0_0_1, 1_0_1_1, 1_1_0_1, 1_1_1_1' => 'Daily Top Spenders'
        );
    }
    
    /*
     * Redemption Status List
     */
    public static function redemptionStatusList($name, $active=NULL, $javascript='', $class ='')
    {    
        $states = array();        
        $states[] = JHTML::_('select.option', '', JText::_('All'), 'value', 'text');
        $statusList = self::redemptionStatusRaw();
        foreach($statusList as $key => $value)
        {
            $states[] = JHTML::_('select.option', $key, $value, 'value', 'text');
        }
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" '.$javascript, 'value', 'text', $active);
        return $state;
    }
    
    public static function redemptionStatusRaw()
    {
        return array(
            '1' => 'Approved',
            '2' => 'Deliver to Outlet',
            '3' => 'Pick Up'
        );
    }
    
    /*
     * Redemption Filter by List
     */
    public static function redemptionFilterByList($name, $active=NULL, $javascript='', $class ='')
    {    
        $states = array();        
        $states[] = JHTML::_('select.option', '', JText::_('All'), 'value', 'text');
        $statusList = self::redemptionFilterByRaw();
        foreach($statusList as $key => $value)
        {
            $states[] = JHTML::_('select.option', $key, $value, 'value', 'text');
        }
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" '.$javascript, 'value', 'text', $active);
        return $state;
    }
    
    public static function redemptionFilterByRaw()
    {
        return array(
            '1' => 'Manual',
            '2' => 'Online'
        );
    }
    
    /*
     * Sex List
     */
    public static function listSex($name, $active=NULL, $javascript='', $class ='')
    {    
        $states = array();        
        $states[] = JHTML::_('select.option', '', JText::_('WRD_OPT_SELECT_ALL'), 'value', 'text');
        $sexList = self::listSexRaw();
        foreach($sexList as $key => $value)
        {
            $states[] = JHTML::_('select.option', $key, $value, 'value', 'text');
        }
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" multiple="multiple"  size="5"  '.$javascript, 'value', 'text', $active);
        return $state;
    }
    
    public static function listSexRaw()
    {
        return array(
            'male' => JText::_('WRD_OPT_SELECT_MALE'),
            'female' => JText::_('WRD_OPT_SELECT_FEMALE')
        );
    }

    public static function listPosition($name, $active=NULL, $javascript='', $class ='')
    {    
        $states = array();        
        $states[] = JHTML::_('select.option', '', JText::_('WRD_OPT_SELECT_ALL'), 'value', 'text');
        $models = self::listPositionRaw();
        foreach($models as $key => $value)
        {
            $states[] = JHTML::_('select.option', $key, $value, 'value', 'text');
        }
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" multiple="multiple"  size="5" '.$javascript, 'value', 'text', $active);
        return $state;
    }
	
    public static function listPositionRaw()
    {
        $query = "
            SELECT id AS `id`
            FROM #__wrd_job
            WHERE id NOT IN(1,3,4,5,7,8)
        ";
        $db = JFactory::getDbo();
        $db->setQuery($query) ;
        $otherPosition = $db->loadObjectList();
        $otherIds = '';
        foreach($otherPosition as $item)
        {
            $otherIds .= $item->id.',';
        }
		
        $otherIds = $otherIds."8";
        return array(
            '1' => JText::_('WRD_OPT_SELECT_CEO_CHAIRMIAN'),
            '3' => JText::_('WRD_OPT_SELECT_DIRECTOR'),
            '4,5,7' => JText::_('WRD_OPT_SELECT_MID_MANAGEMENT_EXECUTIVE_LEVEL'),
            $otherIds => JText::_('WRD_OPT_SELECT_OTHER')
        );
    }
    
    /*
     * Meal Period
     */
    public static function listMealPeriod($name, $active=NULL, $javascript='', $class ='')
    {
        $states = array();        
        $states[] = JHTML::_('select.option', '', ''.JText::_('WRD_OPT_SELECT_ALL').'', 'value', 'text');
        
        $models = self::listMealPeriodRaw();
        foreach($models as $key => $value)
        {
            $states[] = JHTML::_('select.option', $key, $value, 'value', 'text');
        }
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" multiple="multiple"  size="5" '.$javascript, 'value', 'text', $active);
        return $state;
    }
    
    public static function listMealPeriodRaw()
    {
        return array(
            '1' => JText::_('Breakfast'),
            '2' => JText::_('Lunch'),
            '3' => JText::_('Dinner')
        );
    }
    
    public static function listStatusRedemptionRaw($name, $active=NULL, $javascript='', $class ='')
    {
        $states = array();        
        
        $models = self::statusRedemptionRaw();
        foreach($models as $key => $value)
        {
            $states[] = JHTML::_('select.option', $key, $value, 'value', 'text');
        }
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" '.$javascript, 'value', 'text', $active);
        return $state;
    }
	
    public static function statusRedemptionRaw()
    {
        return array(
            '1' => JText::_('Verify and Approve'),
            '2' => JText::_('Deliver to outlet')
        );
    }
    
    /*
     * Complain type
     */
    public static function listComplainType($name, $active=NULL, $javascript='', $class ='')
    {
        $states = array();        
        $states[] = JHTML::_('select.option', '', ''.JText::_('WRD_OPT_SELECT_ALL').'', 'value', 'text');
        
        $models = self::listComplainTypeRaw();
        foreach($models as $key => $value)
        {
            $states[] = JHTML::_('select.option', $key, $value, 'value', 'text');
        }
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" multiple="multiple"  size="5" '.$javascript, 'value', 'text', $active);
        return $state;
    }
	
    public static function listComplainTypeRaw()
    {   
        return array(
            '1' => JText::_('Food'),
            '2' => JText::_('Beverage'),
            '3' => JText::_('Services'),
            '4' => JText::_('Other')
        );
    }
    
    public static function listFilterFieldComplain($name, $active=NULL, $javascript='', $class ='')
    {    
        $states = array();        
        $states[] = JHTML::_('select.option', '', JText::_('WRD_OPT_SELECT_ALL'), 'value', 'text');
        
        $models = self::listFilterFieldComplainRaw();
        foreach($models as $key => $value)
        {
            $states[] = JHTML::_('select.option', $key, $value, 'value', 'text');
        }
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'"  size="1" '.$javascript, 'value', 'text', $active);
        return $state;
    }
    
    public static function listFilterFieldComplainRaw()
    {
        return array(
            '1' => JText::_('Member name'),
            '2' => JText::_('Member id')
        );
    }

    public static function listAges($name, $active=NULL, $javascript='', $class ='')
    {    
        $currentYear = date('Y');     
        
        $states = array();        
        $states[] = JHTML::_('select.option', '', JText::_('All'), 'value', 'text');
        
        $states[] = JHTML::_('select.option', ($currentYear-25).'-'.($currentYear-18), JText::_('Age 18-25'), 'value', 'text');
        $states[] = JHTML::_('select.option', ($currentYear-35).'-'.($currentYear-26), JText::_('Age 26-35'), 'value', 'text');
        $states[] = JHTML::_('select.option', ($currentYear-45).'-'.($currentYear-36), JText::_('Age 36-45'), 'value', 'text');
        $states[] = JHTML::_('select.option', ($currentYear-100).'-'.($currentYear-46), JText::_('Age 46+'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'unknown-unknown', JText::_('Unknown'), 'value', 'text');
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" multiple="multiple"  size="5"  '.$javascript, 'value', 'text', $active);
        return $state;
    }
    
    /*
     * District List
     */
    public static function listDistricts($name, $active=NULL, $javascript='', $class ='')
    {   
        /********** Get id of other districts **********/ 
        $model = JModelLegacy::getInstance('distric','WrdModel');
        $otherModels = $model->getOtherDistrictForStatistic();
        $otherIds = '';
        foreach($otherModels as $item)
        {
            $otherIds .= $item->id.',';
        }
        
        $otherIds = $otherIds.'0';
        
        /********** Merge data **********/
        $states = array();    
        $states[] = JHTML::_('select.option', '', JText::_('All'), 'value', 'text');
        $states = array_merge( $states, $model->getDistrictForStatistic());
        $states[] = JHTML::_('select.option', $otherIds, JText::_('Other'), 'value', 'text');
        
        $state = JHTML::_('select.genericList', $states, $name, 'class="'.$class.'" multiple="multiple"  size="5"  '.$javascript, 'value', 'text', $active );
        return $state;
        
    }
    
    /*
     * For member pending report detail
     */
    public static function listFieldReportSortBy($name, $active=NULL, $javascript='', $class ='')
    {    
        $states = array();        
        $states[] = JHTML::_('select.option', '', JText::_('-- Select --'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'dateasc', JText::_('Date Ascending'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'datedesc', JText::_('Date Desending'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'outlet', JText::_('Outlet'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'meal', JText::_('Meal Period'), 'value', 'text');
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" size=1 '.$javascript, 'value', 'text', $active);
        return $state;
    }
    
    public static function listFieldReportTest($name, $active=NULL, $javascript='', $class ='')
    {    
        $states = array();        
        $states[] = JHTML::_('select.option', '', JText::_('All'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'prefix', JText::_('Title'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'l_name', JText::_('Name'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'job', JText::_('Job Title'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'company', JText::_('Company'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'email', JText::_('Email'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'phone', JText::_('Phone Number'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'total_visit', JText::_('Total visit'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'pax', JText::_('Cover'), 'value', 'text');       
        $states[] = JHTML::_('select.option', 'liquor', JText::_('Points Accumulated'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'food', JText::_('Food'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'beverage', JText::_('BV'), 'value', 'text');
        $states[] = JHTML::_('select.option', 'other', JText::_('Misc.'), 'value', 'text');
        
        $state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" size=15 multiple="multiple" '.$javascript, 'value', 'text', $active);
        return $state;
    }
	
	public static function listCity($name, $active=NULL,$javascript='', $class ='', $order=''){
		$model = &JModelLegacy::getInstance('city','WrdModel');
		$states = array();
		
		$states[] = JHTML::_('select.option', '0',JText::_('WRD_OPT_SELECT_CITY'), 'value', 'text');
		$states[] = JHTML::_('select.option', '1',JText::_('WRD_OPT_SELECT_CITY_HO_CHI_MINH'), 'value', 'text');
		
		$list = $model->getList();
		foreach ($list as $raw=>$item){
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_CITY_'.$list[$raw]->text));
		}
		$states = array_merge( $states, $list);
		
		$state = JHTML::_('select.genericList', $states, $name, 'class="'.$class.'"'.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function countryToCity(){
		$db = JFactory::getDBO();
		$query = 'SELECT id, name, country_id FROM #__wrd_city WHERE published = 1 ORDER BY id,`name` ASC ';
		$db->setQuery($query);
		$state = $db->loadObjectList();
		return $state;
	}
	
	public static function listDistric($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('distric','WrdModel');
		$states = array();
		$states[] = JHTML::_('select.option', '0', JText::_('WRD_OPT_SELECT_DISTRICT'), 'value', 'text');
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_DISTRICT_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);
		$state = JHTML::_('select.genericList', $states, $name, 'class="'.$class.'"'.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function cityToDistric(){
		$db = &JFactory::getDBO();
		$query = 'SELECT id, name, city_id FROM #__wrd_distric WHERE published = 1 ORDER BY ordering,name ASC ';
		$db->setQuery($query);
		$state = $db->loadObjectList();
		return $state;
	}
	
	public static function job_prefix($active=0,$javascript='',$first = 1, $class=''){
		$states[] = JHTML::_('select.option', '-1', '- '.JText::_('WRD_OPT_SELECT_JOB_TITLE').' -', 'value', 'text');
		$states[] = JHTML::_('select.option', 's', JText::_( 'WRD_OPT_SELECT_JOB_TITLE_SENIOR' ));
		$states[] = JHTML::_('select.option', 'd', JText::_( 'WRD_OPT_SELECT_JOB_TITLE_DEPUTY' ));
		$states[] = JHTML::_('select.option', 'v', JText::_( 'WRD_OPT_SELECT_JOB_TITLE_VICE' ));
		$states[] = JHTML::_('select.option', 'a', JText::_( 'WRD_OPT_SELECT_JOB_TITLE_ASSISTANT' ));
        $states[] = JHTML::_('select.option', 'm', JText::_( 'WRD_OPT_SELECT_JOB_TITLE_ADMIN' ));
        $states[] = JHTML::_('select.option', 'e', JText::_( 'WRD_OPT_SELECT_JOB_TITLE_ACADEMIC' ));
        $states[] = JHTML::_('select.option', 'c', JText::_( 'WRD_OPT_SELECT_JOB_TITLE_ACCOUNT' ));
        $states[] = JHTML::_('select.option', 'other', JText::_( 'WRD_OPT_SELECT_JOB_TITLE_ORTHER' ));
        
		$state = JHTML::_('select.genericList', $states,'job_prefix', 'class="'.$class.'" size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function listJob($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('job','WrdModel');
		$states = array();	
		
		$states[] = JHTML::_('select.option', '0',JText::_('WRD_OPT_SELECT_JOB'), 'value', 'text');
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
			
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_JOB_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);
		if($order==e){
			$states[] = JHTML::_('select.option', 'other', JText::_('WRD_OPT_SELECT_JOB_OTHER'), 'value', 'text');
		}
		$state = JHTML::_('select.genericList', $states, $name, 'class="job '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	public static function listJobReport($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('job','WrdModel');
		$states = array();	
		
		$states[] = JHTML::_('select.option', '0',JText::_('ALL'), 'value', 'text');
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
			
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_JOB_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);
		/*if($order==e){
			$states[] = JHTML::_('select.option', 'other', JText::_('WRD_OPT_SELECT_JOB_OTHER'), 'value', 'text');
		}*/
		$state = JHTML::_('select.genericList', $states, $name, 'class="job '.$class.'"  multiple="multiple" size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	public static function listBation($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('bation','WrdModel');
		$states = array();	
		
		$states[] = JHTML::_('select.option', '0',JText::_('WRD_OPT_SELECT_BUSINESS_ASSOCIATION'), 'value', 'text');
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
				
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_JOB_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);
		
		if($order==5){
			$states[] = JHTML::_('select.option', 'other', JText::_('WRD_OPT_SELECT_BUSINESS_ASSOCIATION_OTHER'), 'value', 'text');
		}
		$state = JHTML::_('select.genericList', $states,$name, 'class="bation '.$class.'"  style=" height: 100px;" multiple="multiple" size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	public static function listOutletsFilter($name, $active=NULL, $javascript='', $class =''){
		$model = &JModelLegacy::getInstance('outlets','WrdModel');
		$states = array();
		
		$states[] = JHTML::_('select.option', '-1', '- '.JText::_('WRD_OPT_SELECT_OUTLETS').' -', 'value', 'text');
		$states = array_merge( $states, $model->getList());
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'"'.$javascript, 'value', 'text', $active);
		return $state;
	}
	public static function listOutletsEx($name,$active=NULL,$javascript='',$class ='',$flag_pcode = 0, $condition=''){
        $model = &JModelLegacy::getInstance('outlets','WrdModel');
        $states = array();
        
        $states[] = JHTML::_('select.option', '', ''.JText::_('WRD_OPT_SELECT_ALL').'', 'value', 'text');
        $states = array_merge( $states, $model->getList($condition));
        $state = JHTML::_('select.genericList', $states , $name, 'class="'.$class.'" multiple="multiple"  size="5" '.$javascript, 'value', 'text', $active );
        return $state;
    }
	
	public static function listIndustryReport($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('industry','WrdModel');
		$states = array();	

		$states[] = JHTML::_('select.option', '0', '- '.JText::_('All').' -', 'value', 'text');
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_INDUSTRY_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="industry '.$class.'" multiple="multiple"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listIndustry($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('industry','WrdModel');
		$states = array();	

		$states[] = JHTML::_('select.option', '0', '- '.JText::_('WRD_OPT_SELECT_INDUSTRY').' -', 'value', 'text');
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_INDUSTRY_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);
		$states[] = JHTML::_('select.option', 'other', JText::_('WRD_OPT_SELECT_BUSINESS_INDUSTRY_OTHER'), 'value', 'text');
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="industry '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listDepartment($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('department','WrdModel');
		$states = array();	
		
		$states[] = JHTML::_('select.option', '0', '- '.JText::_('WRD_OPT_SELECT_DEPARTMENT').' -', 'value', 'text');
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_DEPARTMENT_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);	
		$states[] = JHTML::_('select.option', 'other',JText::_('WRD_OPT_SELECT_OTHER'), 'value', 'text');
		$state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listDepartmentReport($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('department','WrdModel');
		$states = array();	
		
		$states[] = JHTML::_('select.option', '0', '- '.JText::_('All').' -', 'value', 'text');
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_DEPARTMENT_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);	
		$state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'" multiple="multiple"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listEducation($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('education','WrdModel');
		$states = array();	
		
		$states[] = JHTML::_('select.option', '0',JText::_('WRD_OPT_SELECT_EDUACATION'), 'value', 'text');
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_EDUACATION_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);
	
		if($order==5){
			$states[] = JHTML::_('select.option', 'other', JText::_('WRD_OPT_SELECT_EDUACATION_OTHER'), 'value', 'text');
		}
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="education '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listOClub($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('oclub','WrdModel');
		$states = array();	
		
		$states[] = JHTML::_('select.option', '0',JText::_('WRD_OPT_SELECT_OTHER_CLUB'), 'value', 'text');
		
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_EDUACATION_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);		
		if($order==5){
			$states[] = JHTML::_('select.option', 'other', JText::_('WRD_OPT_SELECT_OTHER_CLUB_OTHER'), 'value', 'text');
		}
		$state = JHTML::_('select.genericList', $states,$name, 'class="o_club'.$class.'" multiple="multiple" style=" height: 100px; " size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}

	public static function listIncome($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('income','WrdModel');
		$states = array();	
		
		$states[] = JHTML::_('select.option', '0', JText::_('WRD_OPT_SELECT_INCOME') , 'value', 'text');
		
		$list = $model->getList();
		
		foreach ($list as $raw=>$item){
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_INCOME_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);

		$state = JHTML::_('select.genericList', $states,$name, 'class="income '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listStatus($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		$model = &JModelLegacy::getInstance('status','WrdModel');
		$states = array();
		$states[] = JHTML::_('select.option', '0',JText::_('WRD_OPT_SELECT_STATUS'), 'value', 'text');
		$list = $model->getList();
		foreach ($list as $raw=>$item){
				
			$list[$raw]->text= JText::_(WrdHelper::stringURLSafeAliasLang('WRD_OPT_SELECT_STATUS_'.$list[$raw]->text));
		}
		
		$states = array_merge( $states, $list);
		$state = JHTML::_('select.genericList', $states,$name, 'class="status '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listDateOfMonth($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		$states[] = JHTML::_('select.option', '', JText::_( 'WRD_OPT_SELECT_DAY' ));
		for($i = 1; $i<=31 ; $i++){
			$states[] = JHTML::_('select.option', $i, $i);
		}
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="day_of_month '.$class.'" size="1" ', 'value', 'text', $active );
		return $state;
	}
	
	public static function listHours($name, $active=NULL,$javascript='', $class ='', $order='', $size=1,$j=true){
		$states[] = JHTML::_('select.option', '0', JText::_( 'WRD_OPT_SELECT_HOUR' ));
		
		for($i = 0; $i<24 ; $i++){
			$states[] = JHTML::_('select.option', $i, $i);
		}
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="day_of_month '.$class.'" size="1" ', 'value', 'text', $active );
		return $state;
	}
	public static function listMinute($name, $active=NULL,$javascript='', $class ='', $order='', $size=1,$j=true){
		$states[] = JHTML::_('select.option', '0', JText::_( 'WRD_OPT_SELECT_MINUTE' ));
		
		for($i = 0; $i<60 ; $i++){
			$states[] = JHTML::_('select.option', $i, $i);
		}
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="day_of_month '.$class.'" size="1" ', 'value', 'text', $active );
		return $state;
	}
	public static function listMonthOfYear($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		$states[] = JHTML::_('select.option', '', JText::_( 'WRD_OPT_SELECT_MONTH' ));
		for($i = 1; $i<=12 ; $i++){
			$states[] = JHTML::_('select.option', $i, $i);
		}
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="day_of_month '.$class.'" size="1" ', 'value', 'text', $active );
		return $state;
	}
	
	public static function listYear($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		$states[] = JHTML::_('select.option', '', JText::_( 'WRD_OPT_SELECT_YEAR' ));
		$cur_year = date("Y");
		for($i = intval($cur_year-18); $i >= 1900 ; $i--){
			$states[] = JHTML::_('select.option', $i, $i);
		}
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="day_of_month '.$class.'" size="1" ', 'value', 'text', $active );
		return $state;
	}
	
	public static function listTpoints($name, $active=NULL,$javascript='', $class ='',$first = 0){
		
		$model_tpoints = &JModelLegacy::getInstance('tpoint','WrdModel');
		$states = array();	
		if($first!=1){
			$states[] = JHTML::_('select.option', '0', '- '.JText::_('WRD_OPT_SELECT').' -', 'value', 'text');
		}
		$states = array_merge( $states, $model_tpoints->getList());
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}

	public static function listNumChildren($name, $active=NULL,$javascript='', $class ='',$first = 0){
		$states = array();	
		if($first != 1){
			$states[] = JHTML::_('select.option', '0', '- '.JText::_('WRD_OPT_SELECT').' -', 'value', 'text');
			$states[] = JHTML::_('select.option', '0', JText::_('WRD_OPT_SELECT_NONE'), 'value', 'text');
		}
		
		for ($i = 1; $i <= 10 ; $i++){
			$states[] = JHTML::_('select.option',$i , $i);
		}
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		
		return $state;
	}
	
	public static function listActionWeekend($name, $active=NULL,$javascript='', $class ='',$first = 0){
		
		$model = &JModelLegacy::getInstance('aweekend','WrdModel');
		$states = array();	
		if($first!=1){
			$states[] = JHTML::_('select.option', '0', '- '.JText::_('WRD_OPT_SELECT').' -', 'value', 'text');
		}
		$states = array_merge( $states, $model->getList());
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function selectRange($name,$userid, $active=NULL,$javascript='', $class ='',$first = 0){
		$db = JFactory::getDbo();
		$query = 'SELECT date_receipt 
					FROM #__wrd_transaction 
					WHERE vip_number ='.$userid.' 
					GROUP BY MONTH( date_receipt ) 
					ORDER BY date_receipt DESC';

		$db->setQuery($query);
		$rs = $db->loadObjectList();
		
		$states[] = JHTML::_('select.option', '', '- '.JText::_('WRD_OPT_SELECT_MONTH').' -', 'value', 'text');
		foreach ($rs as $key => $value) {
			$month = explode('-', $value);
			$states[] = JHTML::_('select.option',$month[1].'-'.$month[2],$month[1].'-'.$month[2], 'value', 'text');
		}
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listStatusSelection($name, $active=NULL, $javascript='', $class ='', $first = 0){
		$states = array();	
		if($first !=1){
			$states[] = JHTML::_('select.option', '0', '- '.JText::_('WRD_OPT_SELECT_STATUS').' -', 'value', 'text');
		}
		$states[] = JHTML::_('select.option', '1', JText::_( 'WRD_OPT_SELECT_WAITING_FOR_VERIFY' ));
		$states[] = JHTML::_('select.option', '2', JText::_( 'WRD_OPT_SELECT_PICK_UP' ));
		$state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function genarateListBox($name, $active=NULL, $javascript ='',$class ='', $from = 0, $to=0, $label = ''){		
		$states = array();	
		$states[] = JHTML::_('select.option',$label,$label, 'value', 'text');
		for($i = $to ; $i >= $from ; $i--){
			$states[] = JHTML::_('select.option', $i, JText::_(''.$i) );
		}
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function listRedemptionStatus($name, $active=NULL, $javascript='', $class ='', $first = 0){
		$states = array();	
		if($first != 1){
			$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Select status').' -', 'value', 'text');
		}
		$states[] = JHTML::_('select.option', '1', JText::_( 'Verify with member' ));
		$states[] = JHTML::_('select.option', '2', JText::_( 'Approve by loyalty program' ));
		$states[] = JHTML::_('select.option', '3', JText::_( 'Approve by account' ));
		$states[] = JHTML::_('select.option', '4', JText::_( 'Deliver to outlet' ));
		$states[] = JHTML::_('select.option', '5', JText::_( 'Guest picked up' ));
		$state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	

    public static function listPublishedProducts($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
        $model = &JModelLegacy::getInstance('products','WrdModel');
        $states = array();    
        $states[] = JHTML::_('select.option', '-1', '- '.JText::_('Select a product').' -', 'value', 'text');
        
        if($order != 1){
            $states = array_merge( $states, $model->publishProducts());
        }
        
        $state = JHTML::_('select.genericList', $states, $name, 'class="'.$class.'"'.$javascript, 'value', 'text', $active );
        return $state;
    }
    
    public static function buildScriptSelectCategoryProduct(){
        $model = &JModelLegacy::getInstance('products','WrdModel');
        $models = $model->publishProducts();
      
		$script = ' var categories = new Array(); categories[""] = new Array(); ';
        $scriptProduct = 'var productList = new Array(); productList[""] = new Array(); ';
        $categories = array();
        
        if(!empty($models)) {
            foreach($models as $item)
            {
                $text = unserialize($item->text);
				$item->text = $text['en-GB'];
				$categories[$item->cat_id][] = $item;
            }
            
            foreach($categories as $key => $products)
            {
                $script .= 'categories['.$key.'] = new Array(); ';
                if(!empty($products))
                {
                    $index = 0;
                    foreach($products as $item)
                    {
                        $script .= ' categories['.$key.']['.($index++).'] = ["'.$item->value.'", "'.$item->text.'"]; ';
                        $scriptProduct .= ' productList['.($item->value).'] = ["'.($item->point).'", "'.($item->pointx).'", "'.$item->cash.'"]; ';
                    }
                }            
            }
            
        }
        return $script.' '.$scriptProduct;
    }

    public static function allProductsOfAllCategories(){
        $model = &JModelLegacy::getInstance('products','WrdModel');
        $models = $model->publishProducts();
        return $models;
    }
    
	public static function listProducts($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
        $model = &JModelLegacy::getInstance('products','WrdModel');
        $states = array();    
        $states[] = JHTML::_('select.option', '-1', '- '.JText::_('WRD_OPT_SELECT_PRODUCT').' -', 'value', 'text');
        if($order != 1){
            $states = array_merge( $states, $model->getList());
        }
        $state = JHTML::_('select.genericList', $states, $name, 'class="'.$class.'"'.$javascript, 'value', 'text', $active );
        return $state;
    }
    
    public static function listProductsFilter($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
        $model = &JModelLegacy::getInstance('products','WrdModel');
        $states = array();
        $states[] = JHTML::_('select.option', '', JText::_('WRD_OPT_SELECT_ALL'), 'value', 'text');
		
        $list = $model->getList();
        foreach ($list as $col=>$val){
        	$val->text = unserialize($val->text);
        	$val->text = $val->text['en-GB'];
        	$list[$col] = $val;
        }
        
        if($order != 1){
            $states = array_merge( $states, $list);
        }
		
        $state = JHTML::_('select.genericList', $states, $name, 'class="'.$class.'"'.$javascript, 'value', 'text', $active );
        return $state;
    }
    
	public static function listProductCategory($name, $active=NULL,$javascript='',$class ='', $first=-1 ){
        $model = &JModelLegacy::getInstance('pcategory','WrdModel');
        $states = array();
        $states[] = JHTML::_('select.option', '0', '- '.JText::_('WRD_OPT_SELECT_CATEGORY').' -', 'value', 'text');
        $states = array_merge( $states, $model->getList());
        $state = JHTML::_('select.genericList', $states,$name, 'class="inputbox '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
        return $state;
    }
    
    public static function listProductCategoryStyleTwo($name, $active=NULL,$javascript='',$class ='', $first=-1 ){
        $model = &JModelLegacy::getInstance('pcategory','WrdModel');
        $states = array();
        $states[] = JHTML::_('select.option', '', JText::_('WRD_OPT_SELECT_ALL'), 'value', 'text');
        $states = array_merge( $states, $model->getList());
        $state = JHTML::_('select.genericList', $states,$name, 'class="inputbox '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
        return $state;
    }
    
	public static function CategoryToProduct(){
		$db = &JFactory::getDBO();
		$query = 'SELECT id, name, cat_id FROM #__wrd_products WHERE published = 1 ORDER BY cat_id ';
		$db->setQuery($query);
		$state = $db->loadObjectList();
		return $state;
	}
	
	public static function listFilterTypeDate($name, $active=NULL, $javascript='', $class ='', $first = 0){
		$states = array();	
		$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Filter by').' -', 'value', 'text');
		$states[] = JHTML::_('select.option', '1', JText::_( 'Submission Date' ));
		$states[] = JHTML::_('select.option', '2', JText::_( 'Pick Up Date' ));
		$states[] = JHTML::_('select.option', '3', JText::_( 'Deliver To Outlet Date' ));
		$state = JHTML::_('select.genericList', $states,$name, 'class="'.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function complain_type($active=0,$javascript='',$first = 1, $class=''){
		if($first == 1)
			$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Select a type').' -', 'value', 'text');
		
		$states[] = JHTML::_('select.option', '1', JText::_( 'Food' ));
		$states[] = JHTML::_('select.option', '2', JText::_( 'Beverage' ));
		$states[] = JHTML::_('select.option', '3', JText::_( 'Services' ));
		$states[] = JHTML::_('select.option', '4', JText::_( 'Other' ));
		
		$state = JHTML::_('select.genericList', $states,'complain_type', 'class="'.$class.'" size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}
	
	public static function meal_period($active=0,$javascript='',$first = 1, $class=''){
		if($first == 1)
			$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Select a period').' -', 'value', 'text');
		
		$states[] = JHTML::_('select.option', '1', JText::_( 'Breakfast' ));
		$states[] = JHTML::_('select.option', '2', JText::_( 'Lunch' ));
		$states[] = JHTML::_('select.option', '3', JText::_( 'Dinner' ));

		$state = JHTML::_('select.genericList', $states,'meal_period', 'class="'.$class.'" size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}

	public static function listMsquestions($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		
		$model = &JModelLegacy::getInstance('msquestions','WrdModel');
		$states = array();	
		
		$states[] = JHTML::_('select.option', '0', '- '.JText::_('Select a question').' -', 'value', 'text');
		$states = array_merge( $states, $model->getList());
		
		$state = JHTML::_('select.genericList', $states,$name, 'class="msquestions '.$class.'"  size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	public static function listSources($name, $active=NULL,$javascript='', $class ='', $order='', $size=1, $condition=''){
		
		$model = &JModelLegacy::getInstance('sources','WrdModel');
		$states = array();	
		
		$states[] = JHTML::_('select.option', '0', '- '.JText::_('Select sources').' -', 'value', 'text');
		$tmpArr = $model->getList($condition);
		
		if(is_array($tmpArr)){
			$states = array_merge( $states, $tmpArr);
		}
		
		if($order=='tr'){
			$states[] = JHTML::_('select.option', 'other', JText::_('Others'), 'value', 'text');
		}
		$state = JHTML::_('select.genericList', $states,$name, 'class="bation '.$class.'" size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
	
	public static function available($name,$active=0,$javascript='',$first = 1, $class=''){
		if($first == 1){
			$states[] = JHTML::_('select.option', '-1', '- '.JText::_('Status of number').' -', 'value', 'text');
		}
		$states[] = JHTML::_('select.option', '1', JText::_( 'Available' ));
		$states[] = JHTML::_('select.option', '0', JText::_( 'Not available' ));
		$state = JHTML::_('select.genericList',$states,$name,'class="'.$class.'" size="1" '.$javascript, 'value', 'text', $active);
		return $state;
	}

	public static function listLuckyNumber($name, $active=NULL,$javascript='', $class ='', $order='', $size=1){
		$model = &JModelLegacy::getInstance('lnum','WrdModel');
		$states = array();	
		$states[] = JHTML::_('select.option', '0', '- '.JText::_('Select a number').' -', 'value', 'text');
		$states = array_merge( $states, $model->getList());
		$state = JHTML::_('select.genericList', $states,$name, 'class="bation '.$class.'" size="1" '.$javascript, 'value', 'text', $active );
		return $state;
	}
}
?>